<?php

class Application_Model_WaySplit extends Application_Model_DomainObject{
    
    protected $_id;
    
    protected $_wayId;
    
    protected $_weight; 
    
    protected $_length;
    
    protected $_width; 
    
    protected $_height;
    
    public static function addSplit($wayId,$splitArr)
    {
        $split = self::getDao()->queryAll(array("wayId = "=>$wayId));
        if($split){
            foreach ($split as $val) {
                $val->delete();
            }
        }
        for ($index = 1; $index <= count($splitArr); $index++) {
            $splitItem = new Application_Model_WaySplit();
            $splitItem->WayId = $wayId;
            $splitItem->Weight = $splitArr[$index]["weight"];
            $splitItem->Length = $splitArr[$index]["length"];
            $splitItem->Width = $splitArr[$index]["width"];
            $splitItem->Height = $splitArr[$index]["height"];
            $splitItem->save();
        }
    }
    
    public static function byWayId($wayId)
    {
        return self::getDao()->queryAll(array("wayId = "=>$wayId));
    }
}